<?php
	include_once('templates/templateFunctions.tpl');
	showNavigation($file);
	if($file=="payment"){
	
		paymentTemplate(Members::getMemberList(),$currentDate);
	
	}
	if($file=="summary"){
		
		$date=isset($_GET["month_year"]) ? $_GET["month_year"] : formatDate($currentDate,"Y-m");
		selectMonthForSummary($date);
		showDueChart(Members::getMemberList(),$date);
		showPaymentsMade(AdminActivities::getPaymentDetails(formatDate($date,"Ym")),"Payments Made This Month (".formatDate($date,"Y-m").")");
		$d = new DateTime($date);
		$d->sub(new DateInterval('P1M'));
		$lstMonth = $d->format('Y-m-d');
		showPaymentsMade(AdminActivities::getPaymentDetails(formatDate($lstMonth,"Ym")),"Payments Made Last Month (".formatDate($lstMonth,"Y-m").")");
	
	}
	if($file=="memberDetails"){
		$id=isset($_GET["id"]) ? $_GET["id"] : 1;
		$memberDetails=Members::getMemberDetails($id);
		$month_year=isset($_GET["month_year"]) ? $_GET["month_year"] : formatDate($currentDate,"Ym");
		showListOfUsers(Members::getMemberList(),$id,$month_year);
		showDetails(Members::getPaymentDetails($id,$month_year),$month_year,$memberDetails);
		showMonthPicker($id,$month_year);
		showMemberDetails($memberDetails);
	}
	
	if(isset($_SESSION['notification'])){
		$notification=$_SESSION['notification'];
		$notifyMsg=$notification['msg'];
		$notifyStatus=$notification["status"];
		$notifyHtml="";
		$notifyHtml.=<<<EOT
		<script>
			$(document).ready(function(){
				$.notify("{$notifyMsg}", "{$notifyStatus}");
			});
		</script>
EOT;
		echo $notifyHtml;
		unset($_SESSION['notification']);
	}

	
?>